package org.example.code.test2025.two_month;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class test0225 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int k = in.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = in.nextInt();
        }
        int max = fun3(arr, n, k);
        System.out.println(max);
    }

    private static int fun3(int[] arr, int n, int k) {
        Arrays.sort(arr);
        int max = Integer.MIN_VALUE;
        for(int i=0;i<n;i++){
            int count = 1;
            int op = 0;
            for(int j=0;j<n;j++){
                if(i!=j){
                    op = op + Math.abs(arr[i]-arr[j]);
                    if(op<=k){
                        count++;
                    }
                }
            }
            max = Math.max(max,count);
        }
        return max;
    }

    public static long fun(int[] arr, int n) {
        long[] dp = new long[n];
        dp[0] = arr[0];
        long max = dp[0];
        for (int i = 1; i < n; i++) {
            dp[i] = Math.max(arr[i], dp[i - 1] + arr[i]);
            max = Math.max(max, dp[i]);
        }
        return max;
    }

    public ListNode sortInList(ListNode head) {
        if(head == null||head.next==null){
            return head;
        }
        ListNode s = head;
        ListNode f = head.next;
        while(f!=null&&f.next!=null){
            s=s.next;
            f=f.next.next;
        }
        ListNode temp = s.next;
        s.next=null;
        ListNode left = sortInList(head);
        ListNode right = sortInList(temp);
        return fun2(left,right);
    }

    private ListNode fun2(ListNode left, ListNode right) {
        ListNode temp = new ListNode(0);
        ListNode tail = temp;
        while(left!=null&&right!=null){
            if (left.val< right.val) {
                tail.next = left;
                left = left.next;
            }else{
                tail.next = right;
                right = right.next;
            }
            tail=tail.next;
        }
        tail.next = left!=null?left:right;
        return temp.next;
    }
}

class ListNode {
    int val;
    ListNode next = null;

    public ListNode(int val) {
        this.val = val;
    }
}
